package us.mooresr.geartrack.server.handler;

import us.mooresr.geartrack.server.DAO;
import us.mooresr.geartrack.shared.action.PutPersonAction;
import us.mooresr.geartrack.shared.action.PutPersonResult;
import us.mooresr.geartrack.shared.action.PutItemAction;
import us.mooresr.geartrack.shared.action.PutItemResult;
import us.mooresr.geartrack.shared.model.Person;
import us.mooresr.geartrack.shared.model.Item;

import com.gwtplatform.dispatch.server.ExecutionContext;
import com.gwtplatform.dispatch.server.actionhandler.ActionHandler;
import com.gwtplatform.dispatch.shared.ActionException;

public class PutPersonActionHandler implements
	ActionHandler<PutPersonAction, PutPersonResult> {

	@Override
	public PutPersonResult execute(PutPersonAction action,
			ExecutionContext arg1) throws ActionException {
		DAO dao = new DAO();
		
		Person newPerson = action.getPersonIn();
		
		dao.ofy().put(newPerson);
		
		PutPersonResult result = new PutPersonResult(newPerson);
		
		return result;
	}

	@Override
	public Class<PutPersonAction> getActionType() {
		return PutPersonAction.class;
	}

	@Override
	public void undo(PutPersonAction arg0, PutPersonResult arg1,
			ExecutionContext arg2) throws ActionException {
		
		
	}

}
